//
//  LKBankFoldCell.m
//  YLHelper
//
//  Created by she1323 on 2018/6/13.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKBankFoldCell.h"

@interface LKBankFoldCell()

@property (weak, nonatomic) IBOutlet UILabel *accountCodeLabel;
@property (weak, nonatomic) IBOutlet UILabel *accountNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *bankNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *bankBranchLabel;
@property (weak, nonatomic) IBOutlet UILabel *bankCityLabel;

@property (weak, nonatomic) IBOutlet UIImageView *imgaV;
@property (weak, nonatomic) IBOutlet UILabel *reservdPhoneLabel;


@end


@implementation LKBankFoldCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor whiteColor];
    // Initialization code
}
-(void)setBankModel:(LKBankModel *)bankModel{
    _bankModel = bankModel;
    NSString *bankCode = [NSString stringWithFormat:@"%@%@",@"银行账户卡号：",_bankModel.accountCode];
    NSString *bankName = [NSString stringWithFormat:@"%@%@",@"开户行：",_bankModel.bankName];
    NSString *BankBranch = [NSString stringWithFormat:@"%@%@",@"开户行支行：",_bankModel.bankBranch];
    
    NSString *UsrBankName = [NSString stringWithFormat:@"%@%@",@"户名：",_bankModel.accountName];
//    NSString *bankphotoUrl = [NSString stringWithFormat:@"%@%@",@"银行卡正面复印件：",_bankModel.accountPhotoUrl];
    if (self.isIdentCatogry) {
        self.reservdPhoneLabel.text = [NSString stringWithFormat:@"预留手机号：%@",_bankModel.bankCardTel];
        self.imgaV.hidden = YES;
    }else{
        self.imgaV.hidden = NO;
        self.pitureUrl = [NSString stringWithFormat:@"%@%@",ServerlUrl,_bankModel.accountPhotoUrl];
        self.imgaV.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showBigPicture:)];
        [self.imgaV addGestureRecognizer:tap];
        [self.imgaV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",ServerlUrl,_bankModel.accountPhotoUrl]] placeholderImage:[UIImage imageNamed:@"pic"]];
    }
    if ([_bankModel.isAuthenticated integerValue]) {
        self.confirmBankCardImageView.image = [UIImage imageNamed:@"confirmBankCard"];
    }else{
       self.confirmBankCardImageView.image = [UIImage imageNamed:@"unconfirmBankCard"];
    }
    NSString *bankCity = [NSString stringWithFormat:@"%@%@",@"开户行支行省市：",self.bankModel.bankCity];
    self.accountCodeLabel.text = bankCode;
    self.accountNameLabel.text = UsrBankName;
    self.bankNameLabel.text = bankName;
    self.bankCityLabel.text = bankCity;
    self.bankBranchLabel.text = BankBranch;
    self.isFold = YES;
    
}

/**
 选中图片的点击手势
 
 @param tap 手势
 */
-(void)showBigPicture:(UITapGestureRecognizer *)tap{
    if (!self.pitureUrl) {
        return;
    }
    UIImageView *imageV = (UIImageView *)tap.view;
    NSMutableArray *pictre = [[NSMutableArray alloc] initWithArray:@[self.pitureUrl]];
    [self showWithTouchIntag:0 AndWithPicturesArray:pictre AndSorceImageView:imageV];
}

#pragma mark 图片浏览器使用案例 (image brower use case)

#pragma mark 方式一：使用数组配置数据源
- (void)showWithTouchIntag:(NSInteger )indexPath AndWithPicturesArray:(NSArray *)picturesArray AndSorceImageView:(UIImageView *)currentImageV{
    
    //创建图片浏览器（注意：更多功能请看 YBImageBrowser.h 文件或者 github readme）
    YBImageBrowser *browser = [YBImageBrowser new];
    browser.currentIndex = indexPath;
    
    //配置数据源（图片浏览器每一张图片对应一个 YBImageBrowserModel 实例）
    NSMutableArray *tempArr = [NSMutableArray array];
    [picturesArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        YBImageBrowserModel *model = [YBImageBrowserModel new];
        model.url = [NSURL URLWithString:obj];
        //        [model setImageWithFileName:obj fileType:@"png"];
        model.sourceImageView = currentImageV;
        [tempArr addObject:model];
    }];
    
    browser.dataArray = tempArr;
    
    //    YBImageBrowserFunctionModel *fm = [YBImageBrowserFunctionModel new];
    //    fm.name = @"分享";
    //    browser.fuctionDataArray = @[[YBImageBrowserFunctionModel functionModelForSavePictureToAlbum], fm];
    //展示
    [browser show];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
